#include <bits/stdc++.h>

using namespace std;

// 辛普森积分

double __simpson(double l, double r, function<double(double)> f)
{
    double mid = (l + r) / 2;
    return (r - l) * (f(l) + 4 * f(mid) + f(r)) / 6;
}

double simp(double L, double R, function<double(double)> f, double ans, double eps)
{
    double mid = (L + R) / 2, l = __simpson(L, mid, f), r = __simpson(mid, R, f);
    if (fabs(l + r - ans) <= eps)
        return ans;
    return simp(L, mid, f, l, eps) + simp(mid, R, f, r, eps);
}
